import { TItemPet } from "../../../Message/Db/Tables/TItemPet";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { PetItemInfo } from "./info/PetItemInfo";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class PetConfig
    
    export  class PetConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (PetConfig._instance != null) 
            {
                throw new Error(" PetConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc2 of loc5) 
            {
                loc1 = new TItemPet();
                loc1.code = loc2.code;
                loc1.icon = StringHelper.getString(loc2.icon);
                loc1.codeUnbind = loc2.codeUnbind;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.category = loc2.category;
                loc1.type = loc2.type;
                loc1.level = loc2.level;
                loc1.effect = loc2.effect;
                loc1.effectEx = loc2.effectEx;
                loc1.bind = loc2.bind;
                loc1.career = loc2.career;
                loc1.sell = loc2.sell;
                loc1.sellPrice = loc2.sellPrice;
                loc1.sellUnit = loc2.sellUnit;
                loc1.color = loc2.color;
                loc1.overlay = loc2.overlay;
                loc1.existTime = loc2.existTime;
                loc1.existSpecial = loc2.existSpecial;
                loc1.cdTime = loc2.cdTime;
                loc1.descStr = StringHelper.getString(loc2.descStr);
                loc1.fightType = loc2.fightType;
                loc1.needLevel = loc2.needLevel;
                loc1.modelId = StringHelper.getString(loc2.modelId);
                loc1.avatarId = loc2.avatarId;
                loc1.talentConfig = StringHelper.getString(loc2.talentConfig);
                loc1.maxEnergy = loc2.maxEnergy;
                loc1.initLifeSpan = loc2.initLifeSpan;
                loc1.growthConfig = StringHelper.getString(loc2.growthConfig);
                loc1.spiritConfig = StringHelper.getString(loc2.spiritConfig);
                loc1.speed = loc2.speed;
                loc1.attackDistance = loc2.attackDistance;
                loc1.attackSpeed = loc2.attackSpeed;
                loc1.initPower = loc2.initPower;
                loc1.initAgility = loc2.initAgility;
                loc1.initConstitution = loc2.initConstitution;
                loc1.initBrains = loc2.initBrains;
                loc1.initSpiritual = loc2.initSpiritual;
                loc1.initRelief = loc2.initRelief;
                loc1.initHit = loc2.initHit;
                loc1.initCrit = loc2.initCrit;
                loc1.initPass = loc2.initPass;
                loc1.initSpeededUp = loc2.initSpeededUp;
                loc1.initBlock = loc2.initBlock;
                loc1.initJouk = loc2.initJouk;
                loc1.initToughness = loc2.initToughness;
                loc1.skill1 = loc2.skill1;
                loc1.skill2 = loc2.skill2;
                loc1.skill3 = loc2.skill3;
                loc1.talentConfig = StringHelper.getString(loc2.talentConfig);
                loc1.talkId = loc2.talkId;
                loc3 = new PetItemInfo(loc1);
                this._map[loc1.code] = loc3;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_item_pet.json");
            this.write(loc1);
            return;
        }

        public getInfoByCode(arg1: int): TItemPet
        {
            var loc1=this._map[arg1] as PetItemInfo;
            if (loc1) 
            {
                return loc1.pet;
            }
            return null;
        }

        public getItemInfoByCode(arg1: int): PetItemInfo
        {
            return this._map[arg1];
        }

        public static get instance(): PetConfig
        {
            if (PetConfig._instance == null) 
            {
                PetConfig._instance = new PetConfig();
            }
            return PetConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: PetConfig;
    }
